package com.example.dirviesystem.repository;

import com.example.dirviesystem.entity.DrivingProgress;
import com.example.dirviesystem.entity.StudentInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Optional;

public interface DrivingProgressRepository extends JpaRepository<DrivingProgress, Long> {

    @Query("SELECT dp FROM DrivingProgress dp JOIN dp.student s WHERE s.name LIKE %:name%")
    Page<DrivingProgress> findByStudentNameContaining(
            @Param("name") String name,
            Pageable pageable);

    Optional<DrivingProgress> findByStudent(StudentInfo student);
}
